package org.example.advice;

import org.example.exception.*;
import org.example.utils.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ControllerHandlers {
    @ExceptionHandler
    public @ResponseBody R errorHandler(UserNotExistsException e){
        return R.error(BizCodeEnum.USER_NOT_EXIT.getCode(), BizCodeEnum.USER_NOT_EXIT.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(ParentExitException e){
        return R.error(BizCodeEnum.PARENT_EXIT.getCode(),BizCodeEnum.PARENT_EXIT.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(PermissionsDenyException e){
        return R.error(BizCodeEnum.PERMISSION_DENY.getCode(),BizCodeEnum.PERMISSION_DENY.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(NoClanException e){
        return R.error(BizCodeEnum.NO_CLAN.getCode(),BizCodeEnum.NO_CLAN.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(NoInThisClan e){
        return R.error(BizCodeEnum.NO_IN_THIS_CLAN.getCode(),BizCodeEnum.NO_IN_THIS_CLAN.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(PassWordException e){
        return R.error(BizCodeEnum.PASSWORD_ERROR.getCode(),BizCodeEnum.PASSWORD_ERROR.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(AccountNotExitException e){
        return R.error(BizCodeEnum.ACCOUNT_NOT_EXIT.getCode(),BizCodeEnum.ACCOUNT_NOT_EXIT.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(ShouldNotBeStudent e){
        return R.error(BizCodeEnum.SHOULD_NOT_BE_STUDENT.getCode(),BizCodeEnum.SHOULD_NOT_BE_STUDENT.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(AccountExitException e){
        return R.error(BizCodeEnum.ACCOUNT_EXIT.getCode(),BizCodeEnum.ACCOUNT_EXIT.getMsg());
    }
    @ExceptionHandler
    public @ResponseBody R errorHandler(SenderIdException e){
        return R.error(BizCodeEnum.SEND_ID_ERROR.getCode(),BizCodeEnum.SEND_ID_ERROR.getMsg());
    }
}
